package controle;

import java.io.IOException;
import java.lang.Thread;
import java.net.ServerSocket;
import java.net.Socket;


public class ServidorProtocoloListener extends Thread implements SocketControlConstants{
	
	private ServerSocket serverSocket;
	
	public void run(){
		try{
			this.serverSocket = new ServerSocket(SocketControlConstants.portaProtocloClienteServidor);
			
			while(true)
			{
				System.out.println("Servidor Ativo ma porta: " + SocketControlConstants.portaProtocloClienteServidor);
				Socket conexao = this.serverSocket.accept();
				System.out.println("Nova Conex�o - Ip: " + conexao.getInetAddress().getHostAddress() + "\nTratando novo usu�rio...");
				ServidorProtocoloHandler servidorProtocoloHandler = new ServidorProtocoloHandler(conexao);
				servidorProtocoloHandler.start();
			}
		}
		catch(IOException e){
			e.printStackTrace();
		}
	}
}
